package balance_change_type

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/base-common/headInfo"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/rpc"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type EditBalanceChangeTypeLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 编辑余额变动类型配置
func NewEditBalanceChangeTypeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditBalanceChangeTypeLogic {
	return &EditBalanceChangeTypeLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// EditBalanceChangeType 编辑余额变动类型配置
func (l *EditBalanceChangeTypeLogic) EditBalanceChangeType(req *types.EditBalanceChangeTypeRq) error {
	var reqData = &rpc.EditConfigInoutRq{
		Id:        req.Id,
		TypeId:    req.TypeId,
		Name:      req.Name,
		Value:     req.Value,
		DeletedAt: req.DeleatedAt,
		CreateUid: headInfo.GetTokenUid(l.ctx),
		UpdateUid: headInfo.GetTokenUid(l.ctx),
		TagType:   int32(req.TagType),
		Ip:        headInfo.GetClientIp(l.ctx),
	}

	_, err := l.svcCtx.AssetsRpc.Config.EditConfigInout(l.ctx, reqData)
	if err != nil {
		return err
	}
	return nil
}
